package CaseTraining;

public class CaseDemo07_3 {
    public static void main(String[] args) {
        System.out.println("素数个数为：" + search(101,200));
    }


    //遍历每一个数字，并打印出素数
    public static int search(int start, int end){
        int count = 0;
        for (int i = start; i <= end; i++) {
            if(check(i)){
                System.out.println(i);
                count++;
            }
        }
        return count;
    }

    //判断是否为素数的方法
    public  static boolean check(int data){
        for (int i = 2; i <= data / 2; i++) {
            if(data % i == 0){
                //不是素数
                return false;
            }
        }
        return  true;
    }
}
